package com.lxf.clouduser.controller;

import com.alibaba.fastjson.JSONObject;
import com.lxf.clouduser.service.UserRatingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 罗兴发
 * @data 2025/7/4 15:04
 * @description：用户评分-控制类
 */
@RestController
@CrossOrigin  //跨域
@RequestMapping("/v1")
@Slf4j
public class UserRatingController {
    @Resource
    UserRatingService userRatingService;

    /**
     * 添加用户评分 (以供其他服务调用)
     * @param json
     * @return
     */
    @PostMapping("/addUserRating")
    public String addUserRating(@RequestBody JSONObject json){
        return userRatingService.addUserRating(json);
    }

    /**
     * 获取用户评分 (以供其他服务调用)
     * @param json
     * @return
     */
    @PostMapping("/getUserRatingById")
    public int getUserRatingById(@RequestBody JSONObject json){
        return userRatingService.getUserRatingById(json);
    }

    /**
     * 根据对象类型获取相应评分 (以供其他服务调用)
     * @param json
     * @return
     */
    @PostMapping("/getUserRatingByObjType")
    public String getUserRatingByObjType(@RequestBody JSONObject json){
        return userRatingService.getUserRatingByObjType(json);
    }

    /**
     * 删除所有打分数据
     * @return
     */
    @GetMapping("/delUserRating")
    public int delUserRating(){
        return userRatingService.delUserRating();
    }
}
